home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-19 / iritsm3s.zip / CAGDEDIT.C < prev    next >
C/C++ Source or Header  |  1991-12-18  |  2KB  |  65 lines

  1. /******************************************************************************
  2. * CagdEdit.c - Editing tools of surfaces and Curves.                  *
  3. *******************************************************************************
  4. * Written by Gershon Elber, Sep. 91.                          *
  5. ******************************************************************************/
  6.  
  7. #include "cagd_loc.h"
  8.  
  9. /******************************************************************************
  10. * Modify a single control point in the curve.                      *
  11. ******************************************************************************/
  12. CagdCrvStruct *CagdEditSingleCrvPt(CagdCrvStruct *Crv, CagdCtlPtStruct *CtlPt,
  13.                                    int Index)
  14. {
  15.     CagdBType
  16.     IsNotRational = !CAGD_IS_RATIONAL_CRV(Crv);
  17.     int i,
  18.     Length = Crv -> Length,
  19.     MaxCoord = CAGD_NUM_OF_PT_COORD(Crv -> PType);
  20.     CagdCrvStruct
  21.     *NewCrv = CagdCrvCopy(Crv);
  22.     CagdRType
  23.     **Points = NewCrv -> Points;
  24.  
  25.     if (Crv -> PType != CtlPt -> PtType)
  26.     FATAL_ERROR(CAGD_ERR_PT_OR_LEN_MISMATCH);
  27.     if (Index < 0 || Index >= Length)
  28.     FATAL_ERROR(CAGD_ERR_INDEX_NOT_IN_MESH);
  29.  
  30.     for (i = IsNotRational; i <= MaxCoord; i++)
  31.     Points[i][Index] = CtlPt -> Coords[i];
  32.  
  33.     return NewCrv;
  34. }
  35.  
  36. /*******************************************************************************
  37. * Modify a single control point in the surface.                       *
  38.  ******************************************************************************/
  39. CagdSrfStruct *CagdEditSingleSrfPt(CagdSrfStruct *Srf, CagdCtlPtStruct *CtlPt,
  40.                                int UIndex, int VIndex)
  41. {
  42.     CagdBType
  43.     IsNotRational = !CAGD_IS_RATIONAL_SRF(Srf);
  44.     int i,
  45.     ULength = Srf -> ULength,
  46.     VLength = Srf -> VLength,
  47.     MaxCoord = CAGD_NUM_OF_PT_COORD(Srf -> PType);
  48.     CagdSrfStruct
  49.     *NewSrf = CagdSrfCopy(Srf);
  50.     CagdRType
  51.     **Points = NewSrf -> Points;
  52.  
  53.     if (Srf -> PType != CtlPt -> PtType)
  54.     FATAL_ERROR(CAGD_ERR_PT_OR_LEN_MISMATCH);
  55.     if (UIndex < 0 || UIndex >= ULength ||
  56.     VIndex < 0 || VIndex >= VLength)
  57.     FATAL_ERROR(CAGD_ERR_INDEX_NOT_IN_MESH);
  58.  
  59.     for (i = IsNotRational; i <= MaxCoord; i++)
  60.     Points[i][CAGD_MESH_UV(NewSrf, UIndex, VIndex)] =
  61.         CtlPt -> Coords[i];
  62.  
  63.     return NewSrf;
  64. }
  65.